﻿using System;
using System.Collections.Generic;
 
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Reflection;

namespace MapReduce.Services
{
    public class ExecuteMapService : ExecuteJobService
    {
        public override byte[][] InnerExecute(Object pJobObj, byte[][] pData)
        {
            String key = U.Convert(pData[3]).ToString();
            String val = U.Convert(pData[4]).ToString();

            IMap map = ((IMap)pJobObj);

            return new byte[][] { U.Serialize(map.Execute(key, val)) };
        }
    }


}

/*
MemoryStream stream = new MemoryStream(jobDelegateArr);
BinaryFormatter formatter = new BinaryFormatter();
MapReduce.MapReduce_Old.MapMethod map = (MapReduce.MapReduce_Old.MapMethod)formatter.Deserialize(stream);


IEnumerable<KeyValuePair<String, String>> tmpMapOutput = map(key, val);

MemoryStream opStream = new MemoryStream();
BinaryFormatter opFormatter = new BinaryFormatter();
opFormatter.Serialize(opStream, tmpMapOutput);

return new byte[][]{opStream.ToArray()};
 */